<template>
	<yd-layout id='vipExchange' class=''>
		<div class="header">
			<div class="input_f">
				<input oninput="if(value.length>12)value=value.slice(0,12)" maxlength="12" pattern="\d*"   v-model.trim="inputVal" type="number" placeholder="请输入会员兑换码"/>
			</div>
		</div>
		<div class="btn" @click="btnClick">确认兑换</div>
		<div class="label">
			<div class="label_list">温馨提示：</div>
			<!--<div class="label_list">1、初次开通会员时，只能兑换，无法直接购买</div>
			<div class="label_list">2、兑换码请联系团队领导人获取</div>-->
			<div class="label_list">1、每个兑换码只能兑换使用一次 </div>
			<div class="label_list">2、兑换码一经使用，将与帐号绑定，无法撤销</div>
		</div>
	</yd-layout>
</template>

<script>
	export default{
		components:{
			
		},
		data(){
			return {
				inputVal:''
			}
		},
		created() {
		},
		watch: {
			
		},
		computed: {
			
		},
		mounted(){
			document.title='兑换会员'
		},
		methods:{
			btnClick(){
				if((this.inputVal+'')){
					if((this.inputVal+'').length==12){
						this.$root.ajax({
							name:'member/active',
							params:{
								code:this.inputVal
							}
						}).then((d)=>{
							this.$dialog.toast({
			                    mes: '兑换成功',
			                    timeout: 1500,
			                    icon: 'success',
			                    callback: () => {
			                        this.$router.go(-1)
			                    }
			                });
							
						})
					}else{
						this.$dialog.toast({
		                    mes: '请输入12位兑换码',
		                    timeout: 1500,
		                    callback: () => {
		                    	
		                    }
		                });
					}
				}else{
					this.$dialog.toast({
	                    mes: '请输入兑换码',
	                    timeout: 1500,
	                    callback: () => {
	                    	
	                    }
	                });
				}
			},
		}
	}
</script>

<style lang="scss">
	@import './vipExchange.scss';
</style>